﻿// EphmListDlg.cpp: 实现文件
//

#include "pch.h"
#include "JointSerialTest.h"
#include "EphmListDlg.h"
#include "afxdialogex.h"
#include "Devices.h"

// EphmListDlg 对话框

IMPLEMENT_DYNAMIC(EphmListDlg, CDialogEx)

EphmListDlg::EphmListDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG_EPHMLIST, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

EphmListDlg::~EphmListDlg()
{
}

void EphmListDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_ELIST, datalist);
}

BOOL EphmListDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	SetIcon(m_hIcon, TRUE);			// 设置大图标

	for (size_t k = 0; k < 12; k++)
	{
		datalist.InsertColumn(k, titles[k], LVCFMT_CENTER, width[k]);
	}
	return 0;
}

LRESULT EphmListDlg::addData(WPARAM wParam, LPARAM lParam)
{
	EPHEMRISETABLE* ephtab = (EPHEMRISETABLE*)wParam;
	AEPHEMRISEDATA* ephdata;
	CString nextContent;

	datalist.DeleteAllItems();
	for (INT nextRowNUm = 0; nextRowNUm < 32; nextRowNUm++)
	{
		INT idx = 0;
		ephdata = &(ephtab->ephemrises[nextRowNUm]);
		nextRowNUm = datalist.InsertItem(nextRowNUm, _T(""));
		nextContent.Format(_T("%d"), ephdata->PRN);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%lf"), ephdata->tow);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%d"), ephdata->health);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%d"), ephdata->week);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%lf"), ephdata->toe);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%f"), ephdata->A);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%f"), ephdata->dltN);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%f"), ephdata->M0);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%f"), ephdata->ecc);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%f"), ephdata->omg);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%f"), ephdata->toc);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
		nextContent.Format(_T("%f"), ephdata->tgd);
		datalist.SetItemText(nextRowNUm, idx++, nextContent);
	}
	return LRESULT();
}


BEGIN_MESSAGE_MAP(EphmListDlg, CDialogEx)
	ON_MESSAGE(LISTMSG_GETEPHM, addData)
END_MESSAGE_MAP()


// EphmListDlg 消息处理程序
